import axios from '@/utils/axiosTest'
import qs from 'qs'

export function getRequest(method, url, params) {
  console.log(params)
  if (params !== '{}') {
    params = `?${qs.stringify(params, { arrayFormat: 'repeat' })}`
  }
  return axios({
    url: `${url}${params}`,
    method: method
  })
}

export function formDataRequest(method, url, params) {
  return axios({
    url: url,
    async: true,
    crossDomain: true,
    processData: false,
    contentType: false,
    method: method,
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8;'
    },
    transformRequest: [function() {
      return params
    }],
    data: params
  })
}

export function jsonRequest(method, url, data) {
  return axios({
    url: url,
    method: method,
    data
  })
}

export function restfulRequest(method, url) {
  return axios({
    url: url,
    method: method
  })
}
